Skip to content

[SDK] Fix: Automatically trigger login for connected wallets whe… #7009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

gregfromstl
Copy link
Member

@gregfromstl gregfromstl commented May 11, 2025

…n auth is required

🤖 Generated with Claude Code


PR-Codex overview

This PR introduces automatic SIWE (Sign-In with Ethereum) authentication when a wallet is connected, enhancing user experience by streamlining the login process.

Detailed summary

  • Added siweAuth options to various components for handling SIWE authentication.
  • Updated ConnectButton and ConnectEmbed to utilize siweAuth.
  • Introduced isInAppSigner function to determine in-app wallet status.
  • Modified autoConnectCore to support SIWE login logic.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

…n auth is required

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
@gregfromstl gregfromstl requested review from a team as code owners May 11, 2025 19:27
Copy link

linear bot commented May 11, 2025

Copy link

vercel bot commented May 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2025 9:05pm
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2025 9:05pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2025 9:05pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2025 9:05pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 11, 2025 9:05pm

Copy link

changeset-bot bot commented May 11, 2025

🦋 Changeset detected

Latest commit: a3a9e63

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

graphite-app bot commented May 11, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels May 11, 2025
@gregfromstl gregfromstl added merge-queue Adds the pull request to Graphite's merge queue. and removed packages SDK Involves changes to the thirdweb SDK labels May 11, 2025
Copy link
Member Author

Merge activity

  • May 11, 3:27 PM EDT: The merge label 'merge-queue' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.

// if the wallet is connected and auth is required, trigger a login attempt automatically
useEffect(() => {
if (
activeAccount &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only do this for in app wallets. Coz on mobile you really need an explicit click otherwise things break quickly.

@@ -410,6 +412,28 @@ function ConnectButtonInner(
}
}, [activeAccount]);

// if an IAW wallet is connected and auth is required, trigger a login attempt automatically
useEffect(() => {
const isIAW = activeWallet?.id === "inApp" || adminWallet?.id === "inApp";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a helper for this? That handles smart and ecosystem too

Copy link
Contributor

github-actions bot commented May 11, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 54.21 KB (0%) 1.1 s (0%) 193 ms (+158.44% 🔺) 1.3 s
thirdweb (cjs) 193.92 KB (0%) 3.9 s (0%) 381 ms (+42.27% 🔺) 4.3 s
thirdweb (minimal + tree-shaking) 5.68 KB (0%) 114 ms (0%) 74 ms (+1215.69% 🔺) 187 ms
thirdweb/chains (tree-shaking) 524 B (0%) 11 ms (0%) 13 ms (+575.72% 🔺) 23 ms
thirdweb/react (minimal + tree-shaking) 19.55 KB (0%) 391 ms (0%) 56 ms (+457.44% 🔺) 447 ms

Copy link

codecov bot commented May 11, 2025

Codecov Report

Attention: Patch coverage is 64.28571% with 20 lines in your changes missing coverage. Please review.

Project coverage is 54.60%. Comparing base (557a29a) to head (a3a9e63).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...src/wallets/in-app/core/wallet/is-in-app-signer.ts 23.52% 13 Missing ⚠️
...thirdweb/src/wallets/connection/autoConnectCore.ts 73.33% 3 Missing and 1 partial ⚠️
packages/thirdweb/src/react/web/ui/PayEmbed.tsx 83.33% 2 Missing ⚠️
.../react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7009      +/-   ##
==========================================
- Coverage   54.60%   54.60%   -0.01%     
==========================================
  Files         903      904       +1     
  Lines       57936    57960      +24     
  Branches     3970     3969       -1     
==========================================
+ Hits        31637    31648      +11     
- Misses      26198    26211      +13     
  Partials      101      101              
Flag Coverage Δ
packages 54.60% <64.28%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...b/src/react/web/ui/ConnectWallet/ConnectButton.tsx 54.41% <100.00%> (+1.15%) ⬆️
...ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx 5.60% <100.00%> (-0.18%) ⬇️
.../react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx 19.73% <0.00%> (-0.09%) ⬇️
packages/thirdweb/src/react/web/ui/PayEmbed.tsx 46.42% <83.33%> (+4.42%) ⬆️
...thirdweb/src/wallets/connection/autoConnectCore.ts 85.81% <73.33%> (-1.87%) ⬇️
...src/wallets/in-app/core/wallet/is-in-app-signer.ts 23.52% <23.52%> (ø)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

});
manager.addConnectedWallet(wallet);
} catch {
// no-op
}
}

// Auto-login with SIWE
if (urlToken && activeWallet && props.siweLogin) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to check if it actually requires auth here too. I think you can pass the require auth function down as well maybe?

/**
* @hidden
*/
siweLogin?: () => Promise<void>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need this?

});
manager.addConnectedWallet(wallet);
} catch {
// no-op
}
}

// Auto-login with SIWE
if (urlToken && activeWallet && props.siweAuth?.requiresAuth) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to invoke this? I thought it was a function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should do the same logic that would trigger the sign in button

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a function, it just checks if they're using SIWE

@github-actions github-actions bot added the Playground Changes involving the Playground codebase. label May 11, 2025
@gregfromstl gregfromstl merged commit 5a13ad4 into main May 11, 2025
20 of 23 checks passed
@gregfromstl gregfromstl deleted the greg/tool-4452-telegram-redirect-login-on-ios-embedded-browsers branch May 11, 2025 21:02
@joaquim-verges joaquim-verges mentioned this pull request May 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-queue Adds the pull request to Graphite's merge queue. packages Playground Changes involving the Playground codebase. SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants